﻿using System;
using FeedReaderSample.Model;
using INdTFramework.Http;
using RestSharp;

namespace FeedReaderSample.Service
{
    public class RssService
    {
        private RestSharpWrapper restClient = new RestSharpWrapper("http://g1.globo.com/dynamo/rss2.xml");

        public void GetFeeds(Action<News> success, Action<String> fail)
        {
            DefaultXMLHttpRequest<News, string> request =
                new DefaultXMLHttpRequest<News, string>("/", Method.GET, success, fail);

            restClient.ExecuteAsync(request);
        }

        public void PostFeeds(String postContent, Action<News> success, Action<String> fail)
        {
            DefaultXMLHttpRequest<News, string> request =
                new DefaultXMLHttpRequest<News, string>("/someaddress", Method.POST, success, fail);

            request.AddBody(postContent);

            restClient.ExecuteAsync(request);
        }
    }
}
